/**
 *
 */
import Util;
import OpenApi;
import OpenApiUtil;
import EndpointUtil;

extends OpenApi;


init(config: OpenApi.Config){
  super(config);
  @endpointRule = '';
  
  checkConfig(config);
  @endpoint = getEndpoint('captcha', @regionId, @endpointRule, @network, @suffix, @endpointMap, @endpoint);
}

function getEndpoint(productId: string, regionId: string, endpointRule: string, network: string, suffix: string, endpointMap: map[string]string, endpoint: string) throws: string{
  if (!Util.empty(endpoint)) {
    return endpoint;
  }
  
  if (!Util.isUnset(endpointMap) && !Util.empty(endpointMap[regionId])) {
    return endpointMap[regionId];
  }
  return EndpointUtil.getEndpointRules(productId, regionId, endpointRule, network, suffix);
}

model VerifyCaptchaRequest {
  captchaVerifyParam?: string(name='CaptchaVerifyParam', example='dsjidsjidsjkds*djsjdiskds'),
}

model VerifyCaptchaResponseBody = {
  code?: string(name='Code', example='Success'),
  message?: string(name='Message', example='success'),
  requestId?: string(name='RequestId', description='Id of the request', example='95784F***D39FDC5'),
  result?: {
    verifyResult?: boolean(name='VerifyResult', example='true'),
  }(name='Result'),
  success?: boolean(name='Success', example='true'),
}

model VerifyCaptchaResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: VerifyCaptchaResponseBody(name='body'),
}

/**
 * @summary 验证码验证
 *
 * @param request VerifyCaptchaRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return VerifyCaptchaResponse
 */
async function verifyCaptchaWithOptions(request: VerifyCaptchaRequest, runtime: Util.RuntimeOptions): VerifyCaptchaResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.captchaVerifyParam)) {
    query['CaptchaVerifyParam'] = request.captchaVerifyParam;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'VerifyCaptcha',
    version = '2023-03-05',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary 验证码验证
 *
 * @param request VerifyCaptchaRequest
 * @return VerifyCaptchaResponse
 */
async function verifyCaptcha(request: VerifyCaptchaRequest): VerifyCaptchaResponse {
  var runtime = new Util.RuntimeOptions{};
  return verifyCaptchaWithOptions(request, runtime);
}

model VerifyIntelligentCaptchaRequest {
  captchaVerifyParam?: string(name='CaptchaVerifyParam', example='dsjidsjidsjkds*djsjdiskds'),
  sceneId?: string(name='SceneId'),
}

model VerifyIntelligentCaptchaResponseBody = {
  code?: string(name='Code', example='Success'),
  message?: string(name='Message', example='success'),
  requestId?: string(name='RequestId', description='Id of the request', example='95784F***D39FDC5'),
  result?: {
    verifyCode?: string(name='VerifyCode'),
    verifyResult?: boolean(name='VerifyResult', example='true'),
  }(name='Result'),
  success?: boolean(name='Success', example='true'),
}

model VerifyIntelligentCaptchaResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: VerifyIntelligentCaptchaResponseBody(name='body'),
}

/**
 * @summary 验证码验证
 *
 * @param request VerifyIntelligentCaptchaRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return VerifyIntelligentCaptchaResponse
 */
async function verifyIntelligentCaptchaWithOptions(request: VerifyIntelligentCaptchaRequest, runtime: Util.RuntimeOptions): VerifyIntelligentCaptchaResponse {
  Util.validateModel(request);
  var body : map[string]any = {};
  if (!Util.isUnset(request.captchaVerifyParam)) {
    body['CaptchaVerifyParam'] = request.captchaVerifyParam;
  }
  if (!Util.isUnset(request.sceneId)) {
    body['SceneId'] = request.sceneId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'VerifyIntelligentCaptcha',
    version = '2023-03-05',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary 验证码验证
 *
 * @param request VerifyIntelligentCaptchaRequest
 * @return VerifyIntelligentCaptchaResponse
 */
async function verifyIntelligentCaptcha(request: VerifyIntelligentCaptchaRequest): VerifyIntelligentCaptchaResponse {
  var runtime = new Util.RuntimeOptions{};
  return verifyIntelligentCaptchaWithOptions(request, runtime);
}

